package com.api.regression.group.editdocument;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.UserNotMemberApiException;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class EditDocumentNotParticipant extends AbstractApiTest {

	@Value("#{editgroupdocuments['user.notParticipant'].appId}")
	private String userUrn;

	@Value("#{editgroupdocuments['user.notParticipant'].password}")
	private String userPassword;

	@Value("#{editgroupdocuments['group.toEdit'].urn}")
	private String groupUrn;

	@Value("#{editgroupdocuments['group.toEdit'].documentNotOwnedUrn}")
	private String documentUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { UserNotMemberApiException.class })
	public void testEditFile() throws ZyncroApiException {

		String name = "Name after";
		String description = "Description after";
		String attributes = null;

		getApi().getService(IGroupApiService.class).editDocument(groupUrn, documentUrn, name, description, attributes);

	}
}
